<template>
  <div class="icons">
    <swiper :options="swiperOption" ref="mySwiper">
      <swiper-slide v-for="item in page" :key="item.id">
        <div class="icons-item" v-for="List in item" :key="List.id">
          <img :src="List.imgUrl" :alt="List.title" />
          <p>{{ List.title }}</p>
        </div>
      </swiper-slide>
      <!-- <div class="swiper-pagination" slot="pagination"></div> -->
    </swiper>
  </div>
</template>

<script>
import { swiper, swiperSlide } from "vue-awesome-swiper";
import "swiper/dist/css/swiper.css";
export default {
  props: ["iconsList"],
  name: "homeIcons",
  components: {
    swiper,
    swiperSlide,
  },
  data() {
    return {
      swiperOption: {
        // pagination: {
        //     el: '.swiper-pagination'
        // },
      },
    };
  },
  computed: {
    page() {
      let pages = [];

      this.iconsList.forEach((item, index) => {
        let idex = Math.floor(index / 8);

        if (!pages[idex]) pages[idex] = [];

        pages[idex].push(item);
      });

      // console.log(pages);
      return pages;
    },
  },
};
</script>

<style scoped lang="stylus">
@import '~@/assets/css/common.styl';

.icons {
  width: 100%;
  overflow: hidden;
  background: #fff;
  padding-bottom: 0.2rem;
}

.icons-item {
  width: 25%;
  padding-bottom: 25%;
  height: 0px;
  /* background: #ccc; */
  float: left;
}

.icons-item img {
  width: 1rem;
  height: 1rem;
  display: block;
  margin: 0 auto;
  padding-top: 0.2rem;
}

.icons-item p {
  font-size: 0.28rem;
  text-align: center;
  color: #212121;
  margin-top: 0.1rem;
  tetxtOverflow();
}
</style>>
